package com.oms.base;

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;


/**
 * 类说明：与Spring相关的工具类,该类的所有成员方法均为静态方法,用以获取Spring容器中的
 * 上下文信息
 */

public class SpringContextFactory implements ApplicationContextAware {
	private static ApplicationContext applicationContext;
	
	public static Object getBean(String name){
		return applicationContext.getBean(name);
	}
	
	public static Object getBean(Class clzz){
		return getBean(clzz.getName());
	}
	
	public void setApplicationContext(ApplicationContext applicationContext)
			throws BeansException {
		SpringContextFactory.applicationContext = applicationContext;

	}
}